var urls = {}

export default {
    push(url,callback){

        if(urls[url]) {
            return
        }

        urls[url] = true
        var nav = weex.requireModule('navigator')

        nav.pushFull({url:url},function(){
            urls[url] = false
            if(callback &&  typeof callback === "function") {
                callback()
            }
        })
    },

    pushParam(url,params,callback){

        if(urls[url]) {
            return
        }
        urls[url] = true
        var nav = weex.requireModule('navigator')
        nav.pushFull({url:url,param:params},function(data){
            urls[url] = false
            if(callback &&  typeof callback === "function") {
                callback(data)
            }
        })
    },

    present(url,callback){
        if(urls[url]) {
            return
        }

        var modal = weex.requireModule('modal')

        urls[url] = true
        var nav = weex.requireModule('navigator')
        modal.toast({message:JSON.stringify(urls)})
        nav.presentFull({url:url},function(data){
            urls[url] = false
            if(callback &&  typeof callback === "function") {
                callback(data)
            }
        })
    },

    presentParam(url,params,callback){

        if(urls[url]) {
            return
        }
        urls[url] = true
        var nav = weex.requireModule('navigator')
        nav.presentFull({url:url,param:params},function(data){
            urls[url] = false
            if(callback &&  typeof callback === "function") {
                callback(data)
            }
        })
    }
}